<template>
  <div>
    <div class="wrap">
      <div class="top">
        <img
          v-if="commentData.user.head_img"
          :src="$axios.defaults.baseURL + commentData.user.head_img"
          alt
        />
        <img v-else src="@/assets/logo.png" alt />
        <div class="info">
          <div class="name">{{ commentData.user.nickname }}</div>
          <div class="date">{{ commentData.create_date.split("T")[0] }}</div>
        </div>
        <div class="btn" @click="handleClick">回复</div>
      </div>
      <Parent
        v-if="commentData.parent"
        :parentData="commentData.parent"
        @parentCallReply="parentCallReply"
      />
      <div class="content">{{ commentData.content }}</div>
    </div>
  </div>
</template>

<script>
import Parent from "@/components/comment/Parent";
export default {
  components: {
    Parent,
  },
  props: ["commentData"],
  methods: {
    handleClick() {
      this.$emit("callReply", {
        id: this.commentData.id,
        name: this.commentData.user.nickname,
      });
    },
    parentCallReply(parentInfo) {
      this.$emit("callReply", parentInfo);
    },
  },
};
</script>

<style lang="less" scoped>
.wrap {
  padding: 12 / 360 * 100vw;
  border-bottom: 1px solid #ccc;
}
.top {
  display: flex;
  align-items: center;
  margin-bottom: 10 / 360 * 100vw;
  img {
    width: 36 / 360 * 100vw;
    height: 36 / 360 * 100vw;
    border-radius: 18 / 360 * 100vw;
    object-fit: cover;
    margin-right: 10 / 360 * 100vw;
  }
  .info {
    flex: 1;
    .name {
      font-size: 14 / 360 * 100vw;
    }
    .date {
      font-size: 12 / 360 * 100vw;
      color: #888;
      padding-top: 4 / 360 * 100vw;
    }
  }
  .btn {
    font-size: 14 / 360 * 100vw;
    color: #888;
  }
}
.content {
  padding-top: 10 / 360 * 100vw;
}
</style>
